//package com.zmn.plat.admin.controller.brand;
//
//import java.util.Date;
//import java.util.List;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.shiro.authz.annotation.RequiresPermissions;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.alibaba.fastjson.JSONObject;
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.constant.StatusConsts;
//import com.zmn.common.dto.ResultDTO;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.date.DateUtil;
//import com.zmn.common.utils.string.InitialUtil;
//import com.zmn.common.utils.string.StringUtil;
//import com.zmn.plat.model.entity.brand.BaseBrand;
//
///**
// * @author duanzuocai
// * @version v1.0
// * @modifier tanbiao 20190911 修改排序取消权限控制
// * @since 2018/11/10 14:32
// */
//@Controller
//@RequestMapping("/brand/")
//public class BrandModifyController extends BrandBaseController {
//
//    /**
//     * region 新增/修改
//     *
//     * @param request
//     * @param brand
//     * @return
//     */
//    @SuppressWarnings("Duplicates")
//    @RequiresPermissions("/brand/addEdit.action")
//    @RequestMapping(value = "addEdit")
//    @ResponseBody
//    public ResponseDTO addEdit(HttpServletRequest request, @RequestBody BaseBrand brand) {
//        Date now = DateUtil.getNow();
//
//        int brandId = brand.getBrandId();
//
//        brand.setFirstLetter(InitialUtil.getFristEnName(brand.getName()));
//
//        try {
//            if (brandId == 0) {
//                brand.setCreater(getMcStaffRealName());
//                brand.setCreateTime(now);
//                brandService.insert(brand);
//            } else {
//                brand.setUpdater(getMcStaffRealName());
//                brand.setUpdateTime(now);
//                brandService.updateByKey(brand);
//            }
//
//            return ResponseDTO.success(Integer.toString(brand.getBrandId()), "操作成功！");
//        } catch (org.springframework.dao.DuplicateKeyException ex) {
//            logger.error("品牌【{}】已经存在，不能重复添加！", brand.getName());
//            return ResponseDTO.fail("品牌已经存在，不能重复添加！");
//        } catch (Exception ex) {
//            logger.error(String.format("[zmn]新增/修改品牌失败,area:[%s],ex:[%s]", JSONObject.toJSONString(brand), ex.getMessage()));
//            return ResponseDTO.fail("操作失败！");
//        }
//    }
//
//    @RequestMapping(value = "updateSort")
//    @ResponseBody
//    public ResponseDTO updateSort(HttpServletRequest request, @RequestParam(value = "id", defaultValue = "0") Integer brandId,
//        @RequestParam(value = "sort", defaultValue = "0") Integer sort) {
//
//        if (brandId == 0) {
//            return ResponseDTO.fail("请选择要更改排序的品牌！");
//        }
//        if (sort == 0) {
//            return ResponseDTO.fail("请设置品牌排序值！");
//        }
//
//        brandService.updateSortByKey(brandId, sort, getMcStaffRealName());
//        return ResponseDTO.success(GlobalConsts.SUCCESS_MSG);
//    }
//
//    @RequiresPermissions("/brand/updateStatus.action")
//    @RequestMapping(value = "updateStatus")
//    @ResponseBody
//    public ResponseDTO updateStatus(HttpServletRequest request, @RequestParam(value = "ids", defaultValue = "") String ids,
//        @RequestParam(value = "status", defaultValue = "0") Integer status) {
//        if (StringUtil.isBlank(ids)) {
//            return ResponseDTO.fail("请选择要更改状态的品牌！");
//        }
//        if (status == 0) {
//            return ResponseDTO.fail("请设置品牌状态！");
//        }
//
//        List<Integer> arrayIds = StringUtil.convertStrsToList(ids);
//
//        brandService.updateStatusBatchByKey(arrayIds, status, getMcStaffRealName());
//        return ResponseDTO.success(StatusConsts.STATUS_SUCCESS, GlobalConsts.SUCCESS_MSG);
//    }
//}
